package com.zb.sannuo.thereport.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zb.sannuo.common.domain.search.HglReports;
import com.zb.sannuo.common.domain.vo.ReportVo;
import com.zb.sannuo.thereport.mapper.HglReportsMapper;
import com.zb.sannuo.thereport.service.HglReportsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

@Service
public class HglReportsServiceImpl extends ServiceImpl<HglReportsMapper, HglReports> implements HglReportsService {

    @Resource
    private HglReportsMapper hglReportsMapper;

    @Override
    public List<HglReports> findHgl(String searchParams) {
        ObjectMapper mapper = new ObjectMapper();
        ReportVo reportVo = null;
        if (searchParams != null && !"".equals(searchParams)){
            try {
                reportVo = mapper.readValue(searchParams, ReportVo.class);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        List<HglReports> list = hglReportsMapper.findHgl(reportVo);
        ArrayList arrayList = new ArrayList();
        for (HglReports hglReports : list) {
            hglReports.setHgl(hglReports.getHgl()*100);
            arrayList.add(hglReports);
        }
        return arrayList;
    }
}
